package com.own.business.question.common.em;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * QuestionType
 *
 * @author chenxueli
 * @date 2021/5/17 21:02
 */
@SuppressWarnings("all")
@Getter
@AllArgsConstructor
public enum QuestionType {

    All(0, "全部"),
    SINGLE_CHOICE(1, "单项选择题"),
    MULTIPLE_CHOICE(2, "多项选择题"),
    TRUE_OR_FALSE(3, "判断题"),
    COMPLETION(4, "填空题"),
    SHORT_ANSWER(5, "简答题");

    public static Map<Integer, QuestionType> MAP = new HashMap<>();

    static {
        for (var value : QuestionType.values()) {
            MAP.put(value.getType(), value);
        }
    }

    /**
     * 类型
     */
    private final int type;
    /**
     * 名称
     */
    private final String name;

    /**
     * 是否包含该类型
     *
     * @param type 类型
     * @return 是否包含
     */
    public static boolean has(Integer type) {
        return MAP.containsKey(type);
    }

    /**
     * 获取内容
     *
     * @param type 类型
     * @return 类型
     */
    public static QuestionType get(Integer type) {
        return MAP.get(type);
    }

}
